#!/bin/bash
arg=$1
first=${arg:0:1}
if [[ "$arg" == "" || "$arg" == "/" || "$arg" == "/etc"  || "$arg" == "./" ]];then
	echo "请传入参数"
	exit 1
elif [ "$first" = "." ];then
	arg=`pwd`${arg:1}
elif [ "$first" != "/" ];then
	arg=`pwd`/$arg
fi
read -p "要传输的文件或文件夹为$arg:[y/n]" yn
if [ "$yn" != "y" ];then
	exit 1
fi

if [ `hostname` != bigdata1 ];then
	echo "传输$arg到bigdata1:$(dirname $arg)/"
	rsync -avurz --delete $arg bigdata1:$arg
fi

if [ `hostname` != bigdata2 ];then
	echo "传输$arg到bigdata2:$(dirname $arg)/"
	rsync -avurz --delete $arg bigdata2:$arg
fi
if [ `hostname` != bigdata3 ];then
	echo "传输$arg到bigdata3:$(dirname $arg)/"
	rsync -avurz --delete $arg bigdata3:$arg
fi
echo "同步完成"

